class Solution:
    def equalSubstring(self, s: str, t: str, maxCost: int) -> int:
        # 维护一个窗口，里面s转化为t的子串所需开销 <=maxCost
        ans=0
        left=0
        # 需要消耗的预算
        cnt=0
        for right,c in enumerate(s):
            cnt+=abs(ord(s[right])-ord(t[right]))
            while cnt>maxCost:
                # 移除有边界
                cnt-=abs(ord(s[left])-ord(t[left]))
                left+=1
            # 更新值
            ans=max(ans,right-left+1)
        return ans